package com.huawei.gamebox.service.welfare.gift.card;

import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.store.bean.user.UserLevelInfo;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.service.usercenter.personal.bean.UserSummaryInfoBean;
import com.huawei.gamebox.service.welfare.gift.bean.PlayerLevelCardBean;
import o.AccountBussinessListener;
import o.ccp;
import o.cgz;
import o.chy;
import o.Logger;
import o.eod;
import o.eoj;
import o.eqx;
import o.exp.d;
import o.fbh;
import o.fbn;
import o.fbo;
import o.fbq;

public class PlayLevelCard extends BaseGiftCard implements OnClickListener {
    private TextView ʼ;
    private Handler ʽ = new Handler();
    private TextView ˊ;
    private ImageView ˋ;
    private String ˎ = ("PlayLevelCard" + System.currentTimeMillis());
    private PlayerLevelCardBean ˏ;
    private chy ॱॱ;

    class b implements Runnable {
        private boolean ˋ = false;
        final /* synthetic */ PlayLevelCard ˏ;

        public b(PlayLevelCard playLevelCard, boolean z) {
            this.ˏ = playLevelCard;
            this.ˋ = z;
        }

        public void run() {
            if (this.ˋ && this.ˏ.ॱॱ != null) {
                this.ˏ.ॱॱ.ˏ(0, this.ˏ);
            }
            this.ˏ.ˊ.setVisibility(8);
            fbh.ˋ(new fbq(), new fbn());
        }
    }

    class c implements AccountBussinessListener {
        final /* synthetic */ PlayLevelCard ˋ;
        private boolean ˎ = false;

        public c(PlayLevelCard playLevelCard, boolean z) {
            this.ˋ = playLevelCard;
            this.ˎ = z;
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            if (102 == o_ccp.ˎ) {
                this.ˋ.ʽ.post(new b(this.ˋ, this.ˎ));
            }
            eoj.ˋ().ˊ(this.ˋ.ˎ);
        }
    }

    public PlayLevelCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        this.ˋ = (ImageView) view.findViewById(d.ʿॱ);
        this.ˊ = (TextView) view.findViewById(d.ʻˋ);
        this.ʼ = (TextView) view.findViewById(d.ʼˋ);
        this.ˊ.setOnClickListener(this);
        this.ʼ.setOnClickListener(this);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof PlayerLevelCardBean) {
            this.ˏ = (PlayerLevelCardBean) cardBean;
            CharSequence ॱ = this.ˏ.ॱ();
            if (!TextUtils.isEmpty(ॱ)) {
                this.ʼ.setText(ॱ);
            }
            if (TextUtils.isEmpty(ʻ())) {
                this.ˋ.setVisibility(8);
                this.ˊ.setVisibility(0);
                return;
            }
            this.ˋ.setVisibility(0);
            this.ˊ.setVisibility(8);
            eqx.ˏ(this.ˋ, ʻ(), "app_default_icon");
        }
    }

    public void onClick(View view) {
        if (view.getId() == d.ʻˋ) {
            if (TextUtils.isEmpty(ʻ())) {
                eoj.ˋ().ˎ(this.ˎ, new c(this, false));
                eod.ॱ(this.ॱ);
                return;
            }
            eqx.ˏ(this.ˋ, ʻ(), "app_default_icon");
        } else if (!UserSession.getInstance().isLoginSuccessful()) {
            eoj.ˋ().ˎ(this.ˎ, new c(this, true));
            eod.ॱ(this.ॱ);
        } else if (this.ॱॱ != null) {
            this.ॱॱ.ˏ(0, this);
        }
    }

    private String ʻ() {
        if (UserSession.getInstance().isLoginSuccessful()) {
            UserSummaryInfoBean ˎ = fbo.ˋ().ˎ();
            if (ˎ != null) {
                UserLevelInfo ˋ = ˎ.ˋ();
                if (ˋ != null) {
                    Object ˊ = ˋ.ˊ();
                    if (!TextUtils.isEmpty(ˊ)) {
                        this.ˏ.ˋᐝ(ˊ);
                    }
                }
            }
        } else {
            this.ˏ.ˋᐝ("");
        }
        return this.ˏ.ॱˌ();
    }

    public void ॱ(chy o_chy) {
        this.ॱॱ = o_chy;
    }

    public void ˊ() {
        if (Logger.ˎ()) {
            Logger.ˏ("PlayLevelCard", "destroy PlayLevelCard");
        }
        eoj.ˋ().ˊ(this.ˎ);
    }
}
